package com.kolakcc.loljclient.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;

import com.kolakcc.loljclient.model.Item;
import com.kolakcc.loljclient.model.RecentGame;
import com.kolakcc.loljclient.view.ui.ItemImageLabel;
import com.kolakcc.loljclient.view.ui.renderer.RecentGameListItemRenderer;

public class ProfileView extends KolaView {
	public JList<RecentGame> recentMatchesList;
	JTextField searchField;

	public JLabel championNameLabel;
	public JLabel killsLabel;
	public JLabel deathsLabel;
	public JLabel assistsLabel;
	public JLabel summonerSpell1Label;
	public JLabel summonerSpell2Label;
	public JLabel goldEarnedLabel;

	protected ItemImageLabel item1Label;
	protected ItemImageLabel item2Label;
	protected ItemImageLabel item3Label;
	protected ItemImageLabel item4Label;
	protected ItemImageLabel item5Label;
	protected ItemImageLabel item6Label;

	protected JPanel gameInfo;

	public ProfileView() {
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		this.setLayout(new BorderLayout());
		this.setTitle("Profile");
		this.searchField = new JTextField();

		JTabbedPane tabPane = new JTabbedPane();
		JPanel recentGamesPanel = new JPanel(new BorderLayout());

		
		JPanel recentMatchesPanel = new JPanel(new BorderLayout());
		this.recentMatchesList = new JList<RecentGame>();
		this.recentMatchesList.setCellRenderer(new RecentGameListItemRenderer());
		DefaultListModel<RecentGame> temp = new DefaultListModel<RecentGame>();
		this.recentMatchesList.setModel(temp);
		JScrollPane recentMatchesScroller = new JScrollPane(this.recentMatchesList);
		recentMatchesPanel.add(recentMatchesScroller, BorderLayout.WEST);

		this.gameInfo = new JPanel(new FlowLayout());
		this.item1Label = new ItemImageLabel();
		this.gameInfo.add(this.item1Label);
		this.item2Label = new ItemImageLabel();
		this.gameInfo.add(this.item2Label);
		this.item3Label = new ItemImageLabel();
		this.gameInfo.add(this.item3Label);
		this.item4Label = new ItemImageLabel();
		this.gameInfo.add(this.item4Label);
		this.item5Label = new ItemImageLabel();
		this.gameInfo.add(this.item5Label);
		this.item6Label = new ItemImageLabel();
		this.gameInfo.add(this.item6Label);

		recentMatchesPanel.add(this.gameInfo, BorderLayout.CENTER);

		recentGamesPanel.add(recentMatchesPanel);
		tabPane.addTab("Recent Games", recentGamesPanel);

		this.add(tabPane, BorderLayout.CENTER);
		this.setSize(600, 500);
		this.setVisible(true);
	}

	public void setItems(int item1ID, int item2ID, int item3ID, int item4ID,
			int item5ID, int item6ID) {
		this.gameInfo.removeAll();
		this.item1Label = new ItemImageLabel(Item.getItemFromID(item1ID));
		this.gameInfo.add(this.item1Label);
		this.item2Label = new ItemImageLabel(Item.getItemFromID(item2ID));
		this.gameInfo.add(this.item2Label);
		this.item3Label = new ItemImageLabel(Item.getItemFromID(item3ID));
		this.gameInfo.add(this.item3Label);
		this.item4Label = new ItemImageLabel(Item.getItemFromID(item4ID));
		this.gameInfo.add(this.item4Label);
		this.item5Label = new ItemImageLabel(Item.getItemFromID(item5ID));
		this.gameInfo.add(this.item5Label);
		this.item6Label = new ItemImageLabel(Item.getItemFromID(item6ID));
		this.gameInfo.add(this.item6Label);
		this.gameInfo.revalidate();
	}
}